﻿using System;
using System.Web.UI.WebControls.WebParts;
using Eneta.Portal.Common.Definitions;
using Eneta.Portal.Common;
using Eneta.Portal.Admin.Controls;
using System.Web.UI;

namespace Eneta.Portal.Admin.WebParts
{
    public class AdminMagazineListWebPart : WebPart
    {
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {
                var control = Page.LoadControl("~/_controltemplates/AdminLiteratureListControl.ascx") as AdminLiteratureListControl;
                if (control == null)
                    throw new NullReferenceException("Control is missing! ~/_controltemplates/AdminLiteratureListControl.ascx");
                control.WebUrl = Webs.Magazines;
                control.ContentTypeName = "Ajakiri";
                control.NoItemsLabelText = "Ei leidnud ühtegi kinnitamata ajakirja!";
                Controls.Add(control);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                throw;
            }
        }

        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            return;
        }
        public override void RenderEndTag(HtmlTextWriter writer)
        {
            return;
        }
    }
}
